Version: May 3, 2025

Setting Up a PHP Local Server for Web Development

PHP includes a built-in web server that's perfect for local testing and development — no extra software needed.


When to Use It


Requirements

Check if PHP is installed:

php -v

1. Starting the Server

Navigate to the folder where your PHP files live:

cd /path/to/your/php/project

Then start the server:

php -S localhost:8000

Open a web browser and copy the following in the URL

http://localhost:8000

The above will open your index.html and function as a regular site.

2. (Optional) Serving a Specific Entry File

If your entry point is not index.php, you can specify a router file like this:

php -S localhost:8000 router.php

3. Stopping the Server

Just press CTRL + C in your terminal to stop the server.

Security Note

This PHP server is intended only for development. Do not expose it to the internet — it’s not secure for production use.